<style lang="less" scoped>
  .el-menu-item {
    height: 0px;
  }

  .active {
    display: none;
  }
</style>
<template>
  <div>
    <el-row>
      <el-col :span="24" v-bind:class="{ active: aliPayBack }">
        <div class="grid-content bg-purple-dark"
             style="width: 90%;height: 300px;background: #E2F1E3;margin: auto;border: 2px solid #E2F1E3">
          <div style="margin-top: 20px;margin-left: 20px;color: forestgreen;">
            <i class="fa fa-check-circle" style="color: forestgreen"></i>
            您已充值成功<br>
            预计10分钟之内到账<br>
          </div>
          <div style="margin-top: 20px;margin-left: 20px">
            充值金额：<i class="fa fa-jpy" aria-hidden="true"></i><label>{{totalAmount}}</label><br>
            <!--充值账户：{{userName}}-->
          </div>
        </div>
      </el-col>
      <el-col :span="24" v-bind:class="{ active: unionPayBack }">
        <div class="grid-content bg-purple-dark"
             style="width: 90%;height: 300px;background: #E2F1E3;margin: auto;border: 2px solid #E2F1E3">
          <div style="margin-top: 20px;margin-left: 20px;color: forestgreen;">
            <i class="fa fa-check-circle" style="color: forestgreen"></i>
            您已充值完成<br>
            预计10分钟之内到账<br>
          </div>
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24" style="margin-top: 20px">
        <div class="grid-content bg-purple-dark"
             style="width: 90%;margin: auto;">
          <el-menu mode="vertical" :default-active="$route.path" router class="el-menu-vertical-demo">
            <el-menu-item>
              <el-button @click="backClick">返回客户账号</el-button>
            </el-menu-item>
          </el-menu>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
export default{
  data () {
    return {
      userName: this.$store.state.realName,
      aliPayBack: true,
      unionPayBack: true,
      totalAmount: ''
    };
  },
  methods: {
    backClick () {
      let backUrl = localStorage.getItem('back_url');
      localStorage.removeItem('back_url');
      if (backUrl === '' || backUrl === null || backUrl === undefined) {
        this.$router.push('../../login');
      } else {
        this.$router.push(backUrl);
      }
    }
  },
  // 初始化js
  mounted () {
    let unionPay = window.location.href.indexOf('unionPay');
    if (unionPay !== -1) {
      this.aliPayBack = true;
      this.unionPayBack = false;
    } else {
      this.aliPayBack = false;
      this.unionPayBack = true;
      let params = window.location.hash.split('?')[1];
      let totalAmountName = params.split('&')[0].split('=')[0];
      this.totalAmount = params.split('&')[0].split('=')[1];
      console.log(totalAmountName + '--------' + this.totalAmount);
    }
  }
};
</script>
